<?php
function parameter_queryvars( $qvars )
{
	$qvars[] = 'name';
	$qvars[] = 'enterprise';
	$qvars[] = 'email';
	$qvars[] = 'phone';
	$qvars[] = 'message';
	return $qvars;
}


function custom_submit_contact()
{
	global $wp_query;
	if (isset($wp_query->query_vars['name']))
	{
		$admin_email = get_settings('admin_email');
		$to = $admin_email;
		$sub = "Nuevo contacto";
		$msg = "
		<html>
		<body>
		<h1>Nuevo contacto</h1>
			<p>Nombre: ".$wp_query->query_vars['name']."</p>
			<p>Empresa: ".$wp_query->query_vars['enterprise']."</p>
			<p>E-mail: ".$wp_query->query_vars['email']."</p>
			<p>Tel: ".$wp_query->query_vars['phone']."</p>
			<p>Mensaje: ".$wp_query->query_vars['message']."</p>
		</body>
		</html>
		";

		$headers = array("From: Joe Johnston <jjohn@taskboy.com>",
					 "Content-Type: text/html"
					 );
		$h = implode("\r\n",$headers) . "\r\n";

		wp_mail($to, $sub, $msg, $h);
		return true;
	}else{
		return false;
	}
}
function postImage($post_id){
	global $post;
	$args = array(
	    	    'post_type' => 'attachment',  
	    	    'post_mime_type' => 'image',  
	    	    'numberposts' => -1,  
	    	        'order' => 'ASC',  
	    	    'post_status' => null,  
	    	    'post_parent' => $post_id  
	);
	$attachments = get_posts($args);
	if ($attachments) {
		foreach ($attachments as $attachment) {
			return wp_get_attachment_thumb_url( $attachment->ID );
		}
		//Display image
	}
}
function otherPostImages($post_id){
	global $post;
	$args = array(
				'offset'=>'1',
	    	    'post_type' => 'attachment',  
	    	    'post_mime_type' => 'image',  
	    	    'numberposts' => -1,  
	    	        'order' => 'ASC',  
	    	    'post_status' => null,  
	    	    'post_parent' => $post_id  
	);
	$attachments = get_posts($args);
	if ($attachments) {
		foreach ($attachments as $attachment) {
			return wp_get_attachment_thumb_url( $attachment->ID );
		}
		//Display image
	}
	
add_filter('query_vars', 'parameter_queryvars' );



	
}

